package cn.cnsuh.q326_isPowerOfThree;

/**
 * created by mzk on 2020/07/22
 */
public class Main {
    public static void main(String[] args) {
        int n = 27;
        System.out.println(isPowerOfThree(n));
    }

    static boolean isPowerOfThree(int n) {
        while (n > 1) {
            if (n % 3 == 0) {
                n /= 3;
            } else {
                return false;
            }
        }
        return n == 1;
    }
}
